﻿#ifndef RMSERVO_H
#define RMSERVO_H

#include <QObject>
#include "Can/canopenbus.h"

class RmServo : public QObject
{
    Q_OBJECT
public:
    RmServo(CanOpenBus *canbus, uint8_t nodeid, QObject *parent = nullptr);

    uint8_t nodeid {0};
    uint8_t mServoLocation {0};

    const static uint8_t Cmd_High = 1;  //高电平
    const static uint8_t Cmd_Low = 0;   //低电平
    const static uint32_t CmdList_MoveOrigin = 0x200B01;    //回原点，指令0
    const static uint32_t CmdList_Move45 = 0x200B00;    //夹45规格，指令1

    /*----------------------IO状态位定义--------------------*/
    const static uint8_t IOStatus_InPosition = 0x01;    //到位信号
    const static uint8_t IOStatus_Warn = 0x02;    //报警信号
    const static uint8_t IOStatus_FeedBack = 0x04;    //伺服反馈信号
    const static uint8_t IOStatus_PositionErr = 0x08;    //位置超差
    const static uint8_t IOStatus_SpeedErr = 0x10;    //速度超差
    const static uint8_t IOStatus_LockedRotor = 0x20;    //电机赌转

    bool SetMoveOrigin_SDO();
    bool SetMove45_SDO();
private:
    CanOpenBus *myCanbus {nullptr};
};

#endif // RMSERVO_H
